home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / clib / sys / h / syslog < prev    next >
Text File  |  1996-11-09  |  7KB  |  215 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/clib/sys/h/RCS/syslog,v $
  4.  * $Date: 1996/10/30 21:57:16 $
  5.  * $Revision: 1.1 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: syslog,v $
  10.  * Revision 1.1  1996/10/30 21:57:16  unixlib
  11.  * Initial revision
  12.  *
  13.  ***************************************************************************/
  14.  
  15. /*
  16.  * Copyright (c) 1982, 1986, 1988, 1993
  17.  *    The Regents of the University of California.  All rights reserved.
  18.  *
  19.  * Redistribution and use in source and binary forms, with or without
  20.  * modification, are permitted provided that the following conditions
  21.  * are met:
  22.  * 1. Redistributions of source code must retain the above copyright
  23.  *    notice, this list of conditions and the following disclaimer.
  24.  * 2. Redistributions in binary form must reproduce the above copyright
  25.  *    notice, this list of conditions and the following disclaimer in the
  26.  *    documentation and/or other materials provided with the distribution.
  27.  * 3. All advertising materials mentioning features or use of this software
  28.  *    must display the following acknowledgement:
  29.  *    This product includes software developed by the University of
  30.  *    California, Berkeley and its contributors.
  31.  * 4. Neither the name of the University nor the names of its contributors
  32.  *    may be used to endorse or promote products derived from this software
  33.  *    without specific prior written permission.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  36.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  37.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  38.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  39.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  40.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  41.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  42.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  43.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  44.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  45.  * SUCH DAMAGE.
  46.  *
  47.  *    @(#)syslog.h    8.1 (Berkeley) 6/2/93
  48.  */
  49.  
  50. #define    _PATH_LOG    "/dev/log"
  51.  
  52. /*
  53.  * priorities/facilities are encoded into a single 32-bit quantity, where the
  54.  * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
  55.  * (0-big number).  Both the priorities and the facilities map roughly
  56.  * one-to-one to strings in the syslogd(8) source code.  This mapping is
  57.  * included in this file.
  58.  *
  59.  * priorities (these are ordered)
  60.  */
  61. #define    LOG_EMERG    0    /* system is unusable */
  62. #define    LOG_ALERT    1    /* action must be taken immediately */
  63. #define    LOG_CRIT    2    /* critical conditions */
  64. #define    LOG_ERR        3    /* error conditions */
  65. #define    LOG_WARNING    4    /* warning conditions */
  66. #define    LOG_NOTICE    5    /* normal but significant condition */
  67. #define    LOG_INFO    6    /* informational */
  68. #define    LOG_DEBUG    7    /* debug-level messages */
  69.  
  70. #define    LOG_PRIMASK    0x07    /* mask to extract priority part (internal) */
  71.                 /* extract priority */
  72. #define    LOG_PRI(p)    ((p) & LOG_PRIMASK)
  73. #define    LOG_MAKEPRI(fac, pri)    (((fac) << 3) | (pri))
  74.  
  75. #ifdef SYSLOG_NAMES
  76. #define    INTERNAL_NOPRI    0x10    /* the "no priority" priority */
  77.                 /* mark "facility" */
  78. #define    INTERNAL_MARK    LOG_MAKEPRI(LOG_NFACILITIES, 0)
  79. typedef struct _code {
  80.     char    *c_name;
  81.     int    c_val;
  82. } CODE;
  83.  
  84. CODE prioritynames[] = {
  85.     "alert",    LOG_ALERT,
  86.     "crit",        LOG_CRIT,
  87.     "debug",    LOG_DEBUG,
  88.     "emerg",    LOG_EMERG,
  89.     "err",        LOG_ERR,
  90.     "error",    LOG_ERR,        /* DEPRECATED */
  91.     "info",        LOG_INFO,
  92.     "none",        INTERNAL_NOPRI,        /* INTERNAL */
  93.     "notice",    LOG_NOTICE,
  94.     "panic",     LOG_EMERG,        /* DEPRECATED */
  95.     "warn",        LOG_WARNING,        /* DEPRECATED */
  96.     "warning",    LOG_WARNING,
  97.     NULL,        -1,
  98. };
  99. #endif
  100.  
  101. /* facility codes */
  102. #define    LOG_KERN    (0<<3)    /* kernel messages */
  103. #define    LOG_USER    (1<<3)    /* random user-level messages */
  104. #define    LOG_MAIL    (2<<3)    /* mail system */
  105. #define    LOG_DAEMON    (3<<3)    /* system daemons */
  106. #define    LOG_AUTH    (4<<3)    /* security/authorization messages */
  107. #define    LOG_SYSLOG    (5<<3)    /* messages generated internally by syslogd */
  108. #define    LOG_LPR        (6<<3)    /* line printer subsystem */
  109. #define    LOG_NEWS    (7<<3)    /* network news subsystem */
  110. #define    LOG_UUCP    (8<<3)    /* UUCP subsystem */
  111. #define    LOG_CRON    (9<<3)    /* clock daemon */
  112. #define    LOG_AUTHPRIV    (10<<3)    /* security/authorization messages (private) */
  113. #define    LOG_FTP        (11<<3)    /* ftp daemon */
  114.  
  115.     /* other codes through 15 reserved for system use */
  116. #define    LOG_LOCAL0    (16<<3)    /* reserved for local use */
  117. #define    LOG_LOCAL1    (17<<3)    /* reserved for local use */
  118. #define    LOG_LOCAL2    (18<<3)    /* reserved for local use */
  119. #define    LOG_LOCAL3    (19<<3)    /* reserved for local use */
  120. #define    LOG_LOCAL4    (20<<3)    /* reserved for local use */
  121. #define    LOG_LOCAL5    (21<<3)    /* reserved for local use */
  122. #define    LOG_LOCAL6    (22<<3)    /* reserved for local use */
  123. #define    LOG_LOCAL7    (23<<3)    /* reserved for local use */
  124.  
  125. #define    LOG_NFACILITIES    24    /* current number of facilities */
  126. #define    LOG_FACMASK    0x03f8    /* mask to extract facility part */
  127.                 /* facility of pri */
  128. #define    LOG_FAC(p)    (((p) & LOG_FACMASK) >> 3)
  129.  
  130. #ifdef SYSLOG_NAMES
  131. CODE facilitynames[] = {
  132.     "auth",        LOG_AUTH,
  133.     "authpriv",    LOG_AUTHPRIV,
  134.     "cron",     LOG_CRON,
  135.     "daemon",    LOG_DAEMON,
  136.     "ftp",        LOG_FTP,
  137.     "kern",        LOG_KERN,
  138.     "lpr",        LOG_LPR,
  139.     "mail",        LOG_MAIL,
  140.     "mark",     INTERNAL_MARK,        /* INTERNAL */
  141.     "news",        LOG_NEWS,
  142.     "security",    LOG_AUTH,        /* DEPRECATED */
  143.     "syslog",    LOG_SYSLOG,
  144.     "user",        LOG_USER,
  145.     "uucp",        LOG_UUCP,
  146.     "local0",    LOG_LOCAL0,
  147.     "local1",    LOG_LOCAL1,
  148.     "local2",    LOG_LOCAL2,
  149.     "local3",    LOG_LOCAL3,
  150.     "local4",    LOG_LOCAL4,
  151.     "local5",    LOG_LOCAL5,
  152.     "local6",    LOG_LOCAL6,
  153.     "local7",    LOG_LOCAL7,
  154.     NULL,        -1,
  155. };
  156. #endif
  157.  
  158. #ifdef KERNEL
  159. #define    LOG_PRINTF    -1    /* pseudo-priority to indicate use of printf */
  160. #endif
  161.  
  162. /*
  163.  * arguments to setlogmask.
  164.  */
  165. #define    LOG_MASK(pri)    (1 << (pri))        /* mask for one priority */
  166. #define    LOG_UPTO(pri)    ((1 << ((pri)+1)) - 1)    /* all priorities through pri */
  167.  
  168. /*
  169.  * Option flags for openlog.
  170.  *
  171.  * LOG_ODELAY no longer does anything.
  172.  * LOG_NDELAY is the inverse of what it used to be.
  173.  */
  174. #define    LOG_PID        0x01    /* log the pid with each message */
  175. #define    LOG_CONS    0x02    /* log on the console if errors in sending */
  176. #define    LOG_ODELAY    0x04    /* delay open until first syslog() (default) */
  177. #define    LOG_NDELAY    0x08    /* don't delay open */
  178. #define    LOG_NOWAIT    0x10    /* don't wait for console forks: DEPRECATED */
  179. #define    LOG_PERROR    0x20    /* log to stderr as well */
  180.  
  181. #ifndef KERNEL
  182.  
  183. #if 0
  184. /*
  185.  * Don't use va_list in the vsyslog() prototype.   Va_list is typedef'd in two
  186.  * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one
  187.  * of them here we may collide with the utility's includes.  It's unreasonable
  188.  * for utilities to have to include one of them to include syslog.h, so we get
  189.  * _BSD_VA_LIST_ from <machine/ansi.h> and use it.
  190.  */
  191. #include <machine/ansi.h>
  192. #elif !defined (_BSD_VA_LIST_)
  193. /* In GNU we don't have a <machine/ansi.h> and it would be too painful to
  194.    emulate one.  */
  195. #define __need_va_list
  196. #include <stdarg.h>
  197. #define _BSD_VA_LIST_ __gnuc_va_list
  198. #endif
  199.  
  200. #ifdef __cplusplus
  201. extern "C" {
  202. #endif
  203.  
  204. void    closelog (void);
  205. void    openlog (const char *, int, int);
  206. int    setlogmask (int);
  207. void    syslog (int, const char *, ...);
  208. void    vsyslog (int, const char *, _BSD_VA_LIST_);
  209.  
  210. #ifdef __cplusplus
  211. }
  212. #endif
  213.  
  214. #endif /* !KERNEL */
  215.